home *** CD-ROM | disk | FTP | other *** search
/ PC-Blue - MS DOS Public Domain Library / PC-Blue MS-DOS Public Domain Library - NYACC.iso / vol128 / bench < prev    next >
Encoding:
Text File  |  1986-12-15  |  768 b   |  23 lines

  1. /*
  2. Concatentate strings, using append. If the below is asked, 
  3.  
  4. ?-append( "ABC", "DEF", X ), append( "123", X, Y ), append( Y, "XYZ", Z ),
  5.   printstring( Z ).
  6.  
  7.   you will get: Z = "123ABCDEFXYX", printed out as a list of ASCII codes. */
  8.  
  9. append( [], L, L ).
  10. append( [Z|L1], L2, [Z|L3] ) :- append( L1, L2, L3 ).
  11. printstring( [] ).
  12. printstring( [H|T] ) :- put( H ), printstring( T ).
  13.  
  14.  
  15. /* Corresponds to approximately 482 logical inferences. 
  16.    Commonly used as a benchmark: */
  17.  
  18. lips(L) :- rev( [1,2,3,4,5,6,7,8,9,0,11,12,13,14,15,16,17,18,19,20,
  19.               21,22,23,24,25,26,27,28,29,30], L ).
  20.  
  21. rev( [], [] ).
  22. rev( [H|T], L ) :- rev( T,Z), append( Z, [H], L ).
  23.